/**
 * 
 */
package org.statewalker.template;

public class XmlWriteUtil {

    public static void escapeName(StringBuilder buf, String str) {
        buf.append(str);
    }

    public static void escapeValue(StringBuilder buf, String str) {
        if (str == null)
            return;
        char[] array = str.toCharArray();
        for (int i = 0; i < array.length; i++) {
            char ch = array[i];
            switch (ch) {
                case '\t':
                case '\n':
                case '\r':
                case '\'':
                    buf.append("&#x" + Integer.toHexString(ch) + ";");
                    break;
                default: {
                    buf.append(array[i]);
                    break;
                }
            }
        }
    }

}